﻿using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Easy.BLL;
using Easy.Operation;
using Easy.Operation.Expression;

namespace Easy.Web.Service.Data
{
    /// <summary>
    /// GetEntityTip 的摘要说明
    /// </summary>
    public class GetEntityTip : BaseHttpHandler
    {

        public override void ProcessRequest(HttpContext context)  
        {
            context.Response.ContentType = "text/plain";
            string data = context.Request["d"]; 
            JArray ja = (JArray)JsonConvert.DeserializeObject(data);
            List<Dictionary<string, object>> responsedata = new List<Dictionary<string, object>>(); 
            for (int i = 0; i < ja.Count; i++)
            {
                Dictionary<string, object> dt = new Dictionary<string, object>();
                string e = ja[i]["e"].ToString();
                string v = ja[i]["v"].ToString();
                dt.Add("e",e);
                DataService service = new DataService(e, this.CurrentUserId); 
                Dictionary<string, object> returnValue = service.RetrieveMultiple_List(v, null, "", 1, 10);
                dt.Add("tip", returnValue["Total"]);

                responsedata.Add(dt); 
            }

            context.Response.Write(JsonConvert.SerializeObject(responsedata));


        }
    }
}